import java.util.ArrayList;
import java.util.Random;

public class App {
    
    public static void main(String[] args) throws Exception {
        //设置变量
        ArrayList<String> list = new ArrayList<String>();
        Random r = new Random();
        StringBuilder emoji = new StringBuilder();//表情
        char[] eyes = {'a','q','w','i','!','$','^','*','@','&','+','x'};
        char[] mounth = {'w','o','a','-','+','*','o','O','x','u','z','y','l','v','_','='};
        char[] faces = {'(',')','[',']','{','}'};
        char[] hands = {'/','\\','—','~','7','9','6'};
        char[] part = new char[10];//器官序号
        char[][] all = new char[5][30];//元素集
        int i = 0; int j = 0; int k = 0;
        all[0] = mounth; all[1] = eyes; all[2] = faces; all[3] = hands; all[4] = part;//加载元素库

        j = r.nextInt(5) + 2;//产出的表情数
        for(k = 0;k < j;k++)
        {
            for(i = 0;i < 7;i++)//一个表情由7个字符组成
            {
                if(i == 4)
                {
                emoji.reverse();//将 嘴-左眼-左脸-左手 反转为 左手-左脸-左眼-嘴（-右眼-右脸-右手）
                }
                if(i < 4)//第一部分：左手-左脸-左眼-嘴
                {
                    if(i == 2)//确保脸的序号为偶数，脸型为左
                    {
                    part[i] = (char)(r.nextInt(all[i].length) / 2 * 2 + '0');
                    }
                    else
                    {
                    part[i] = (char)(r.nextInt(all[i].length) + '0');
                    }
                    emoji = assemble(all[i], emoji, part,i);
                }
                else//第二部分：右眼-右脸-右手
                {
                    if(i == 5)//将左脸反转为右脸
                    {
                        all[4][i - 3]++;
                    }
                    emoji = assemble(all[i - 3], emoji, part,i - 3);
                }
            }
            list.add(emoji.toString());
            emoji.delete(0, emoji.length());
        }
        System.out.printf("\nlist = " + list + "\n\n");
    }
    public static StringBuilder assemble(char[] chs,StringBuilder str,char[] part,int times)//安装表情字符
    {
        str.append(chs[(part[times] - '0')]);
        return str;
    }
}
